package com;

public class Dog {
    //狗的信息。设定属性包括：品种，年龄，性别，名字；方法包括：叫，跑。
    /**1) 设置属性的私有访问权限，通过公有的getter和setter方法实现对属性的访问

     2) 限定性别只能有“雌性”和“雄性”，如果无效输入进行提示，默认设置“雄性”。

     3) 设置构造函数实现对属性赋值*/
    private String strain;
    private int age;
    private String gender;
    private String name;

    public String getStrain() {
        return strain;
    }

    public void setStrain(String strain) {
        this.strain = strain;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        if ("雄性".equals(gender) || "雌性".equals(gender)) {
            this.gender = gender;
        }else {
            this.gender="雄性";
            System.out.println("输入的不是有效性别，默认性别为雄性");
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public Dog(){
        this.gender="雌性";
        this.age=8;
        this.name="轩轩";
        this.strain="中华田园犬";
    }
    public Dog(String gender,int age,String strain,String name){
        this.gender=gender;
        this.name=name;
        this.strain=strain;
        this.age=age;
    }
    public void jump(){
        System.out.println(this.strain+this.name+"在跳");
    }
    public void run(){
        System.out.println(getStrain()+getName()+"再跑");
    }
}
